using System;
using Oracle.ManagedDataAccess.Client;
using OracleInternal.Common;

namespace OracleInternal.TTC
{
	internal class TTCChunkInfo : TTCFunction
	{
		private static int KPDXSHCHUNKINFOFLAGS_KEY = 1;

		private static int KPDXSHCHUNKINFOFLAGS_CHUNK = 2;

		private static int KPDXSHCHUNKINFOFLAGS_SGKEY = 4;

		internal TTCChunkInfo(MarshallingEngine mEngine)
			: base(mEngine, 190, 0)
		{
			m_ttcCode = 17;
		}

		internal void AddAsPiggyback(string shardingKey, string superShardingKey, string chunkName)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131328, OracleTraceClassName.TTCChunkInfo, OracleTraceFuncName.AddAsPiggyback);
			}
			m_ttcCode = 17;
			byte[] array = null;
			byte[] array2 = null;
			byte[] array3 = null;
			int num = 0;
			try
			{
				if (shardingKey != null)
				{
					array = m_marshallingEngine.m_dbCharSetConv.ConvertStringToBytes(shardingKey, 0, shardingKey.Length);
					num |= KPDXSHCHUNKINFOFLAGS_KEY;
				}
				if (superShardingKey != null)
				{
					array2 = m_marshallingEngine.m_dbCharSetConv.ConvertStringToBytes(superShardingKey, 0, superShardingKey.Length);
					num |= KPDXSHCHUNKINFOFLAGS_SGKEY;
				}
				if (chunkName != null)
				{
					array3 = m_marshallingEngine.m_dbCharSetConv.ConvertStringToBytes(chunkName, 0, chunkName.Length);
					num |= KPDXSHCHUNKINFOFLAGS_CHUNK;
				}
				m_ttcCode = 17;
				WriteFunctionHeader();
				if (array != null)
				{
					m_marshallingEngine.MarshalPointer();
					m_marshallingEngine.MarshalUB4(array.Length);
				}
				else
				{
					m_marshallingEngine.MarshalNullPointer();
					m_marshallingEngine.MarshalUB4(0L);
				}
				if (array3 != null)
				{
					m_marshallingEngine.MarshalPointer();
					m_marshallingEngine.MarshalUB4(array3.Length);
				}
				else
				{
					m_marshallingEngine.MarshalNullPointer();
					m_marshallingEngine.MarshalUB4(0L);
				}
				if (array2 != null)
				{
					m_marshallingEngine.MarshalPointer();
					m_marshallingEngine.MarshalUB4(array2.Length);
				}
				else
				{
					m_marshallingEngine.MarshalNullPointer();
					m_marshallingEngine.MarshalUB4(0L);
				}
				m_marshallingEngine.MarshalUB4(num);
				if (array != null)
				{
					m_marshallingEngine.MarshalCHR(array);
				}
				if (array3 != null)
				{
					m_marshallingEngine.MarshalCHR(array3);
				}
				if (array2 != null)
				{
					m_marshallingEngine.MarshalCHR(array2);
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)268566528, OracleTraceClassName.TTCChunkInfo, OracleTraceFuncName.AddAsPiggyback, ex);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)131584, OracleTraceClassName.TTCChunkInfo, OracleTraceFuncName.AddAsPiggyback);
				}
			}
		}
	}
}
